#!/bin/bash
#********************************************************************
# 时间同步脚本并自动设置时区为 Asia/Shanghai
# Author: zhangjunjie
# Date: 2022-05-27
# FileName： install_ntp_for_centos.sh
#********************************************************************
yum install ntpdate -y
systemctl restart ntpdate
systemctl enable ntpdate
ntpdate ntp1.aliyun.com
timedatectl set-timezone Asia/Shanghai
hwclock -w
echo "*/5 * * * * /usr/sbin/ntpdate -u ntp1.aliyun.com >/dev/null &" >> /var/spool/cron/root
